package cn.njupt.unionfind;
//路径减半，是对路径压缩的一种优化
public class Quick_Union_Rank_PathHalfing extends Quick_Union_Rank{

    public Quick_Union_Rank_PathHalfing(int capacity) {
        super(capacity);
    }

    @Override
    public int find(int child) {
        rangCheck(child);
        while(child!=parent[child]){
            parent[child]=parent[parent[child]];
            child=parent[child];

        }
        return parent[child];
    }
}
